package com.yida.gwj.config.service.impl;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.yida.common.core.utils.DateUtils;
import com.yida.gwj.api.domain.GwjConfDictData;
import com.yida.gwj.config.mapper.GwjConfDictDataMapper;
import com.yida.gwj.config.service.IGwjConfDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务字典数据Service业务层处理
 *
 * @author ruoyi
 * @date 2023-02-28
 */
@Service
public class GwjConfDictDataServiceImpl implements IGwjConfDictDataService {
    @Autowired
    private GwjConfDictDataMapper gwjConfDictDataMapper;

    /**
     * 查询业务字典数据
     *
     * @param dictCode 业务字典数据主键
     * @return 业务字典数据
     */
    @Override
    public GwjConfDictData selectGwjConfDictDataByDictCode(Long dictCode) {
        return gwjConfDictDataMapper.selectGwjConfDictDataByDictCode(dictCode);
    }

    /**
     * 查询业务字典数据列表
     *
     * @param gwjConfDictData 业务字典数据
     * @return 业务字典数据
     */
    @Override
    public List<GwjConfDictData> selectGwjConfDictDataList(GwjConfDictData gwjConfDictData) {
        return gwjConfDictDataMapper.selectGwjConfDictDataList(gwjConfDictData);
    }

    /**
     * 新增业务字典数据
     *
     * @param gwjConfDictData 业务字典数据
     * @return 结果
     */
    @Override
    public int insertGwjConfDictData(GwjConfDictData gwjConfDictData) {
        gwjConfDictData.setCreateTime(DateUtils.getNowDate());
        if (StrUtil.isBlank(gwjConfDictData.getDictLabel())) {
            gwjConfDictData.setDictLabel(IdUtil.simpleUUID());
        }
        return gwjConfDictDataMapper.insertGwjConfDictData(gwjConfDictData);
    }

    /**
     * 修改业务字典数据
     *
     * @param gwjConfDictData 业务字典数据
     * @return 结果
     */
    @Override
    public int updateGwjConfDictData(GwjConfDictData gwjConfDictData) {
        gwjConfDictData.setUpdateTime(DateUtils.getNowDate());
        return gwjConfDictDataMapper.updateGwjConfDictData(gwjConfDictData);
    }

    /**
     * 批量删除业务字典数据
     *
     * @param dictCodes 需要删除的业务字典数据主键
     * @return 结果
     */
    @Override
    public int deleteGwjConfDictDataByDictCodes(Long[] dictCodes) {
        return gwjConfDictDataMapper.deleteGwjConfDictDataByDictCodes(dictCodes);
    }

    /**
     * 删除业务字典数据信息
     *
     * @param dictCode 业务字典数据主键
     * @return 结果
     */
    @Override
    public int deleteGwjConfDictDataByDictCode(Long dictCode) {
        return gwjConfDictDataMapper.deleteGwjConfDictDataByDictCode(dictCode);
    }

    @Override
    public GwjConfDictData getByDictLabel(String dictLabel) {
        return gwjConfDictDataMapper.getByDictLabel(dictLabel);
    }
}
